Use case: program and read operations ¶
|
HAL1 |
HAL2 |
|---|---|
|
The HAL NOR driver is designed to use a high-level API that abstracts the CFI commands. |
The HAL NOR driver provides the user with CFI 0001, 0002, and 0003 APIs for program and read operations. |
Sequence diagram ¶
Note
In HAL1, the program API passes the data to be written by address. In HAL2, the APIs pass the data by value because one data item is used at a time.
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
/* Program API */
HAL_NOR_Program(&hnor,
(uint32_t *)NOR_StartAddress,
&program_data
/* --- */
);
HAL_NOR_ReturnToReadMode(&hnor);
/* Read API */
HAL_NOR_ReadBuffer(&hnor,
(uint32_t *)NOR_StartAddress,
read_data_buffer,
buffer_size
);
|
/* Program API for command set ID 0001 */
HAL_NOR_CFI_0001_Program(&hnor,
(uint32_t *)NOR_StartAddress,
program_data,
1000 // 1000 ms
);
HAL_NOR_CFI_0001_Reset(&hnor);
/* Read API for command set ID 0001 */
HAL_NOR_CFI_0001_ReadArray(&hnor,
(uint32_t *)NOR_StartAddress,
read_data_buffer,
buffer_size
);
|
Key changes ¶
HAL2 splits most APIs by command set ID (CFI 0001/0002/0003).
HAL2 uses command-set specific reset and read-array APIs (
HAL_NOR_CFI_000x_Reset()andHAL_NOR_CFI_000x_ReadArray()).

